package ar.com.maddes.creenciasadventistas;

import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import ar.com.maddes.creenciasadventistas.database.Creencia;

import com.actionbarsherlock.app.SherlockFragment;

public class StripBeliefFragment extends SherlockFragment {
	/**
	 * The fragment argument representing the section number for this fragment.
	 */
	public static final String ARG_BELIEF_NUMBER = "belief_number";
	public static final String ARG_BELIEF_DESCRIPTION = "belief_description";
	private TextView mTextView;
	private LinearLayout mLinearLayout;
	private ScrollView mScrollView;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		View view = inflater.inflate(R.layout.fragment_creencia, null);
		mTextView = (TextView) view.findViewById(R.id.textView1);
		mLinearLayout = (LinearLayout) view.findViewById(R.id.linearLayout1);
		mScrollView = (ScrollView) view.findViewById(R.id.scrollView1);

		new LoadTitle().execute(getArguments().getLong(ARG_BELIEF_NUMBER));
		return view;
	}

	private class LoadTitle extends AsyncTask<Long, Object, String> {
		@Override
		protected String doInBackground(Long... params) {
			return Creencia.getString(Creencia.DESCRIPTION, params[0]);
		}

		@Override
		protected void onPostExecute(String description) {
			super.onPostExecute(description);
			mTextView.setText(description);
			mLinearLayout.setVisibility(View.GONE);
			mScrollView.setVisibility(View.VISIBLE);

		}
	}
}
